using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Cliente.Objetos;

namespace Cliente.Forms
{
    public partial class FormGrid : Form
    {
        public FormGrid()
        {
            InitializeComponent();
        }

        public bool Pj = false;

        private void button1_Click(object sender, EventArgs e)
        {
            Pj = rbPF.Checked ? false : true;
            Controller.Pessoa.PopularGrid(this.dg,tbxNome.Text,Pj);                
        }

        private void bgPesq_DoWork(object sender, DoWorkEventArgs e)
        {

        }

        private void dg_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {/*
            if (e.RowIndex > -1)
            {
                App.oFormCadastroPessoa.PopulateForms(this.dg.Rows[e.RowIndex]);
                this.Close();
            }*/
        }

        private void dg_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }

        private void button3_Click(object sender, EventArgs e)
        {
            String iCod = dg.SelectedRows[0].Cells[0].Value.ToString(); 
            //exclui logicamente, e, no envio para o server, avisa
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (!Pj)
            {
                //String iCod = dg.SelectedRows[0].Cells[0].Value.ToString();
                Model.Pessoa.BindaComboPJ(App.oFormCadastroPessoa.ucCadastroPessoa1.cbxEmpresa);
                App.oFormCadastroPessoa.PopulateForms(dg.SelectedRows[0]);
                App.ShowCadastroPF(); 
            }
            else
            {
                Model.Pessoa.BindaComboPJ(App.oFormCadastroPessoa.ucCadastroPessoa1.cbxEmpresa);
                App.oFormCadastroPJ.PopulateForms(dg.SelectedRows[0]);
                App.ShowCadastroPJ(); 
            }

            this.Close();
        }

        private void tbxNome_TextChanged(object sender, EventArgs e)
        {

        }

        private void tbxNome_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Pj = rbPF.Checked ? false : true;
                Controller.Pessoa.PopularGrid(this.dg, tbxNome.Text, Pj);                

            }
        }
    }
}